
var loginData="";
//注册事件监听
function connectWebViewJavascriptBridge(callback) {
    if (window.WebViewJavascriptBridge) {
        callback(WebViewJavascriptBridge)
    } else {
        document.addEventListener(
            'WebViewJavascriptBridgeReady'
            , function() {
                callback(WebViewJavascriptBridge)
            },
            false
        );
    }
}
//注册回调函数，初始化函数
connectWebViewJavascriptBridge(function(bridge) {
    bridge.init(function(message, responseCallback) {
        console.log('JS got a message', message);
        var data = {
            'Javascript Responds': '测试中文!'
        };
        console.log('JS responding with', data);
        responseCallback(data);
    });

    bridge.registerHandler("functionInJs", function(data, responseCallback) {
        //console.log("初始化从java拿到的数据: = " + data);
        loginData=data;
        var responseData = "Javascript get data:"+data;
        responseCallback(responseData);
    });
});

function backToAndroid() {
    //call native method
    window.WebViewJavascriptBridge.callHandler(
        'submitFromWeb'
        , {'param': "AngularJs Learn More"}
        , function(responseData) {
            console.log("响应成功");
        }
    );
}
function getLoginData(){
    //return loginData;
    return "18811409691;123456";
}